package com.sky.mapper;

import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper {

    void insertOrders(Orders order);


    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);
@Select("select * from orders where id=#{id}")
    Orders selectOrder(Long id);

    List<OrderVO> getOrders(OrdersPageQueryDTO orders);

    OrderStatisticsVO countOrderStatusNumber();


    Integer countOrders(Integer status, LocalDateTime begin, LocalDateTime end);

    List<Orders> getOrdersByStatusAndOrderTime(Integer status, LocalDateTime time);


    Integer countOrdersAmount(Integer status, LocalDateTime begin, LocalDateTime end);

    List<GoodsSalesDTO> selectTop10(Integer status, LocalDateTime begin, LocalDateTime end);

    OrderOverViewVO countAllOrdersStatus();
}
